% TEST_ID: LANG-EXPAND-0116
% CATEGORY: language/string
% 测试 string 的替换

function test_string_replaceBetween()
str = "The quick brown fox";
newStr = replaceBetween(str,"quick "," fox","red")
result = "The quick red fox";
assert(newStr == result);

str = ["The quick brown fox jumps";"over the lazy dog"];
newText = ["red";"sleeping"];
newStr = replaceBetween(str,["quick ";"the "],[" fox";" dog"],newText);
result = ["The quick red fox jumps"
    "over the sleeping dog"];
assert(newStr == result);

str = "Edgar Allen Poe";
newStr = replaceBetween(str,7,11,'A.');
result = "Edgar A. Poe";
assert(newStr == result);

str = ["Edgar Allen Poe";"Louisa May Alcott"];
newText = ["A.";"M."];
newStr = replaceBetween(str,[7;8],[11;10],newText);
result = ["Edgar A. Poe"
    "Louisa M. Alcott"];
assert(newStr == result);

str = "small|medium|large";
newText = "regular";
newStr = replaceBetween(str,6,13,newText,'Boundaries','exclusive');
result = "small|regular|large";
assert(newStr == result);

str = "The quick brown fox jumps over the lazy dog";
newText = "red bird flies";
newStr = replaceBetween(str,'brown','jumps',newText,'Boundaries','inclusive');
result = "The quick red bird flies over the lazy dog";
assert(newStr == result);

end
